/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Demo;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 *
 * @author SaHa
 */
public class CDeserializacion 
{
    public static void main(String[] args)
    {
        CAgenda a1=null;
        CAgenda a2=null;

        try
        {
            //abrir o recuperar un archivo de disco
            FileInputStream fis=new FileInputStream("agenda1.ser");
            //stream para recuperar o reconstruir objetos
            ObjectInputStream ois=new ObjectInputStream(fis);
            //el metodo readObjets() recupera el objeto
            a1=(CAgenda) ois.readObject();
            a2=(CAgenda) ois.readObject();
            ois.close();
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        catch (ClassNotFoundException e)
        {
            e.printStackTrace();
        }
        
        System.out.println(a1);
        System.out.println(a2);
    }        
}
